package fileshare.datastructure;
public class UniContainer
{
private volatile boolean hdsk=false;//whether receive the handshake
private volatile boolean SendSignal=false;//
private boolean stopflag=false;
private  volatile int targetpeerindex;
private  MsgQue recvmsgque;//=new MsgQue("receiver");
private  MsgQue sendmsgque;//=new MsgQue("sender");
private  volatile int targetpeerid;
public UniContainer()
{
	recvmsgque=new MsgQue("receiver");
	sendmsgque=new MsgQue("sender");
}
/**
 * the flag for whether the handshake msg has been received or not
 * @param value
 */
public  void chghdsk(boolean value)
{
	hdsk=value;
}
public   boolean gethdsk()
{
	return hdsk;
}
public  void chgsig(boolean value)
{
	SendSignal=value;
}
public   boolean getsig()
{
	return SendSignal;
}
public  void puttargetindex( int index)
{
	targetpeerindex=index;
}
public int gettargetindex()
{
	return targetpeerindex;
}
public void puttargetid( int index)
{
	targetpeerid=index;
}
public int gettargetid()
{
	return targetpeerid;
}
/*
 * add to sender queue a msg
 */
public void addToSender(byte[]n,int length)
{
	sendmsgque.add(n,  length);;
	
}
/**
 * get a msg from the sender queue
 * @return
 */
public Msg getFromSender()
{
	return sendmsgque.remove();
	
}
/*
 * add to receiver queue a msg
 */
public void addToRecever(byte[]n,int length)
{
	recvmsgque.add(n,  length);;
	
}
/**
 * get a msg from the receiver queue
 * @return
 */
public Msg getFromRecever()
{
	return recvmsgque.remove();
	
}
public void stop()
{
	stopflag=true;
}
public boolean checkstop()
{
	return stopflag;
	}
}